/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import item.ItemList;
import item.TitleReportMgt;
import javax.swing.JFrame;
import transactions.CustomerList;
import transactions.OutstandingLateChargeMgt;
import user.Employee;

/**
 *
 * @author nacerkhalil
 */
public class ManagerFrame extends javax.swing.JFrame {

    /**
     * Creates new form ManagerFrame
     */
    public ManagerFrame(JFrame parent) {
        initComponents();
        this.parent = parent; 
        
        //INITIALIZE PANELS
        deleteCustomer = new DeleteCustomer();
        addTitle = new AddTitle();
        deleteTitle = new DeleteTitle();
        addCopy = new AddCopy();
        cancelLateCharge = new CancelLateCharge();
        reportsPanel = new ReportsPanel("");
        setRental = new SetRental();
        closeAll();
    }
    
    public void closeAll()
    {
        deleteCustomer.setVisible(false);
        addTitle.setVisible(false);
        deleteTitle.setVisible(false);
        addCopy.setVisible(false);
        cancelLateCharge.setVisible(false);
        reportsPanel.setVisible(false);
        setRental.setVisible(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuItem7 = new javax.swing.JMenuItem();
        jMenuBar2 = new javax.swing.JMenuBar();
        jMenu5 = new javax.swing.JMenu();
        jMenu6 = new javax.swing.JMenu();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu9 = new javax.swing.JMenu();
        jMenuItem10 = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        deleteCustomerMenu = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        addTitleMenu = new javax.swing.JMenuItem();
        deleteTitleMenu = new javax.swing.JMenuItem();
        addCopyMenu = new javax.swing.JMenuItem();
        deleteCopyMenu = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        cancelLateChargeButton = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenu7 = new javax.swing.JMenu();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenuItem8 = new javax.swing.JMenuItem();
        jMenu8 = new javax.swing.JMenu();
        jMenuItem9 = new javax.swing.JMenuItem();

        jMenuItem7.setText("jMenuItem7");

        jMenu5.setText("File");
        jMenuBar2.add(jMenu5);

        jMenu6.setText("Edit");
        jMenuBar2.add(jMenu6);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jMenu9.setText("File");

        jMenuItem10.setText("Logout");
        jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem10ActionPerformed(evt);
            }
        });
        jMenu9.add(jMenuItem10);

        jMenuBar1.add(jMenu9);

        jMenu1.setText("Manager Customer");
        jMenu1.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N

        deleteCustomerMenu.setText("Delete customer");
        deleteCustomerMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteCustomerMenuActionPerformed(evt);
            }
        });
        jMenu1.add(deleteCustomerMenu);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Manage titles");

        addTitleMenu.setText("Add title");
        addTitleMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addTitleMenuActionPerformed(evt);
            }
        });
        jMenu2.add(addTitleMenu);

        deleteTitleMenu.setText("Delete title");
        deleteTitleMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteTitleMenuActionPerformed(evt);
            }
        });
        jMenu2.add(deleteTitleMenu);

        addCopyMenu.setText("Add copy");
        addCopyMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addCopyMenuActionPerformed(evt);
            }
        });
        jMenu2.add(addCopyMenu);

        deleteCopyMenu.setText("Delete copy");
        deleteCopyMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteCopyMenuActionPerformed(evt);
            }
        });
        jMenu2.add(deleteCopyMenu);

        jMenuBar1.add(jMenu2);

        jMenu3.setText("Manage  late charge");

        cancelLateChargeButton.setText("Cancel late charge");
        cancelLateChargeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelLateChargeButtonActionPerformed(evt);
            }
        });
        jMenu3.add(cancelLateChargeButton);

        jMenuBar1.add(jMenu3);

        jMenu4.setText("Customer reports");

        jMenuItem1.setText("produce name and basic info report");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem1);

        jMenuItem2.setText("Total number of Items out");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem2);

        jMenuItem3.setText("Information about overdue Items");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem3);

        jMenuItem4.setText("Information about fines owed");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem4);

        jMenuBar1.add(jMenu4);

        jMenu7.setText("Item reports");

        jMenuItem5.setText("Name and basic information");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu7.add(jMenuItem5);

        jMenuItem6.setText("Total number of copies owed");
        jMenuItem6.setToolTipText("");
        jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem6ActionPerformed(evt);
            }
        });
        jMenu7.add(jMenuItem6);

        jMenuItem8.setText("Number of reservations pending for items");
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem8ActionPerformed(evt);
            }
        });
        jMenu7.add(jMenuItem8);

        jMenuBar1.add(jMenu7);

        jMenu8.setText("Setting");

        jMenuItem9.setText("set rental parameters");
        jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem9ActionPerformed(evt);
            }
        });
        jMenu8.add(jMenuItem9);

        jMenuBar1.add(jMenu8);

        setJMenuBar(jMenuBar1);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 818, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 459, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void deleteCustomerMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteCustomerMenuActionPerformed
        closeAll();
        this.setContentPane(deleteCustomer);
        deleteCustomer.setVisible(true);
    }//GEN-LAST:event_deleteCustomerMenuActionPerformed

    private void addTitleMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addTitleMenuActionPerformed
        closeAll();
        this.setContentPane(addTitle);
        addTitle.setVisible(true);
    }//GEN-LAST:event_addTitleMenuActionPerformed

    private void deleteTitleMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteTitleMenuActionPerformed
        closeAll();
        this.setContentPane(deleteTitle);
        deleteTitle.setVisible(true);
    }//GEN-LAST:event_deleteTitleMenuActionPerformed

    private void addCopyMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addCopyMenuActionPerformed

        closeAll();
        this.setContentPane(addCopy);
        addCopy.setVisible(true);
    }//GEN-LAST:event_addCopyMenuActionPerformed

    private void deleteCopyMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteCopyMenuActionPerformed

        closeAll();
        this.setContentPane(addCopy);
        addCopy.setVisible(true);
    }//GEN-LAST:event_deleteCopyMenuActionPerformed

    private void cancelLateChargeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelLateChargeButtonActionPerformed
        closeAll();
        this.setContentPane(cancelLateCharge);
        cancelLateCharge.setVisible(true);
    }//GEN-LAST:event_cancelLateChargeButtonActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        closeAll();
        this.setContentPane(reportsPanel);
        reportsPanel.setReport(TitleReportMgt.produceBasicInfoReport());
        reportsPanel.setVisible(true);
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
        closeAll();
        this.setContentPane(reportsPanel);
        reportsPanel.setReport(TitleReportMgt.produceDetailedReport());
        reportsPanel.setVisible(true);
    }//GEN-LAST:event_jMenuItem6ActionPerformed

    private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
        closeAll();
        this.setContentPane(reportsPanel);
        reportsPanel.setReport(TitleReportMgt.produceReservationItemReport());
        reportsPanel.setVisible(true);
    }//GEN-LAST:event_jMenuItem8ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        closeAll();
        this.setContentPane(reportsPanel);
        reportsPanel.setReport(CustomerList.produceBasicInfoReport());
        reportsPanel.setVisible(true);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        
        closeAll();
        this.setContentPane(reportsPanel);
        reportsPanel.setReport(CustomerList.producTotalRentedItemReport());
        reportsPanel.setVisible(true);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
        closeAll();
        this.setContentPane(setRental);
        setRental.setVisible(true);
    }//GEN-LAST:event_jMenuItem9ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        closeAll();
        this.setContentPane(reportsPanel);
        reportsPanel.setReport(OutstandingLateChargeMgt.produceOutstandingReport());
        reportsPanel.setVisible(true);
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        closeAll();
        this.setContentPane(reportsPanel);
        reportsPanel.setReport(ItemList.ReportOverdue());
        reportsPanel.setVisible(true);
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jMenuItem10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem10ActionPerformed
        this.setVisible(false);
        this.parent.setVisible(true);
    }//GEN-LAST:event_jMenuItem10ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ManagerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ManagerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ManagerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ManagerFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                LoginFrame frame  = new LoginFrame();
                new ManagerFrame(frame).setVisible(true);
            }
        });
    }
    
    //PARENT FRAME
    JFrame parent;
    //PANELS
    DeleteCustomer deleteCustomer;
    AddTitle addTitle;
    DeleteTitle deleteTitle;
    AddCopy addCopy;
    CancelLateCharge cancelLateCharge;
    ReportsPanel reportsPanel;
    SetRental setRental;
    
    
    //EMPLOYEE CONNECTED
    public static Employee employee;
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem addCopyMenu;
    private javax.swing.JMenuItem addTitleMenu;
    private javax.swing.JMenuItem cancelLateChargeButton;
    private javax.swing.JMenuItem deleteCopyMenu;
    private javax.swing.JMenuItem deleteCustomerMenu;
    private javax.swing.JMenuItem deleteTitleMenu;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenu jMenu6;
    private javax.swing.JMenu jMenu7;
    private javax.swing.JMenu jMenu8;
    private javax.swing.JMenu jMenu9;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuBar jMenuBar2;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem10;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    // End of variables declaration//GEN-END:variables
}
